package com.ireadbooks.service.impl;

import com.ireadbooks.entity.OrderLog;
import com.ireadbooks.dao.OrderLogDao;
import com.ireadbooks.service.OrderLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (OrderLog)表服务实现类
 *
 * @author wut
 * @since 2020-04-04 18:06:56
 */
@Service("orderLogService")
public class OrderLogServiceImpl implements OrderLogService {
    @Resource
    private OrderLogDao orderLogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public OrderLog queryById(Integer id) {
        return this.orderLogDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderLog> queryAllByLimit(int offset, int limit) {
        return this.orderLogDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderLog 实例对象
     * @return 实例对象
     */
    @Override
    public OrderLog insert(OrderLog orderLog) {
        this.orderLogDao.insert(orderLog);
        return orderLog;
    }

    /**
     * 修改数据
     *
     * @param orderLog 实例对象
     * @return 实例对象
     */
    @Override
    public OrderLog update(OrderLog orderLog) {
        this.orderLogDao.update(orderLog);
        return this.queryById(orderLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.orderLogDao.deleteById(id) > 0;
    }
}